<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
</head>
<body>
<div class="layui-form" style="padding: 40px">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名:</label>
        <div class="layui-input-block">
            <input type="text" th:value="${user.userName}" disabled lay-verify="required" autocomplete="off"
                   class="layui-input layui-disabled">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别:</label>
        <div class="layui-input-block">
            <select name="sex">
                <option value="男" th:selected="${user.sex eq '男'}">男</option>
                <option value="女" th:selected="${user.sex eq '女'}">女</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名:</label>
        <div class="layui-input-block">
            <input type="text" name="realName" th:value="${user.realName}" lay-verify="title" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机:</label>
        <div class="layui-input-block">
            <input type="text" name="iphone" th:value="${user.iphone}" lay-verify="phone" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">E-mail:</label>
        <div class="layui-input-block">
            <input type="text" name="email" th:value="${user.email}" lay-verify="email" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系地址:</label>
        <div class="layui-input-block">
            <input type="text" name="address" th:value="${user.address}" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="position: fixed;bottom: 0px;right: 10px">
        <div class="layui-input-block">
            <input th:value="${user.id}" name="id" hidden=""/>
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="Submit">保存内容</button>
            <button type="" class="layui-btn layui-btn-primary close">取消</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            form = layui.form;
        $('.close').on('click', function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        })
        form.on('submit(Submit)', function (data) {
            data.field.status = "1"
            $.ajax({
                url: '/user/user.do',
                type: 'put',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (!result.status) {
                        parent.layer.msg(result.msg, {time: 2000});
                        return false;
                    } else {
                        parent.layer.msg("修改成功!", {time: 1000});
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        parent.layui.table.reload('tableId', {});
                    }
                }

            });
        });
    });

</script>
</body>
</html>
